/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package transferObject;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;

/**
 *
 * @author mwiatrowski
 */
public class BlackWhiteImageTO {

    private BufferedImage frame;

    public BufferedImage getFrame() {
        return this.frame;
    }

    public void setFrame(BufferedImage frame) {
        this.frame = frame;
    }

    public void getBlackWhite(Rectangle[] rect, int width, int height) {
        if (rect != null) {
            frame = new BufferedImage(width, height, BufferedImage.TYPE_3BYTE_BGR);
            Graphics2D graph = frame.createGraphics();
            graph.setPaint(Color.white);
            graph.fillRect(0, 0, frame.getWidth(), frame.getHeight());
            for (Rectangle r : rect) {
                graph = frame.createGraphics();
                graph.setColor(Color.black);
                graph.fill(new Rectangle((int) r.getX(), (int) r.getY(), (int) r.getWidth(), (int) r.getHeight()));
            }
        }

    }
}
